package com.atguigu.tingshu.account.service;

import com.atguigu.tingshu.model.account.RechargeInfo;
import com.atguigu.tingshu.model.account.UserAccount;
import com.atguigu.tingshu.model.account.UserAccountDetail;
import com.atguigu.tingshu.vo.account.AccountLockResultVo;
import com.atguigu.tingshu.vo.account.AccountLockVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

public interface UserAccountService extends IService<UserAccount> {


    

    /**
     * 查看用户充值记录
     * @param pageParam
     * @param userId
     * @return
     */
    IPage<UserAccountDetail> findUserRechargePage(Page<UserAccountDetail> pageParam, Long userId);
    /**
     * 为指定账户充值
     * @param userId
     * @param rechargeAmount
     */
    void add(Long userId, BigDecimal rechargeAmount);
    void saveUserAccount(Long aLong);

    /**
     * 获取账户的余额
     * @param userId
     * @return
     */
    BigDecimal getAvailableAmount(Long userId);

    /**
     * 获取账户的信息
     */

    UserAccount getUserAccount(Long userId);

    /**
     *检查及锁定账户金额
     * @param userId
     * @param accountLockVo
     * @return
     */
    AccountLockResultVo checkAndLock(Long userId, AccountLockVo accountLockVo);


    /**
     * 保存账户变动日志记录
     * @param userId
     * @param title
     * @param tradeType
     * @param amount
     * @param orderNo
     */
    void saveUserAccountDetail(Long userId, String title, String tradeType, BigDecimal amount, String orderNo);

    void minus(String orderNo);

    @Transactional(rollbackFor = Exception.class)
    void unlock(String orderNo);

    RechargeInfo getRechargeInfo(String orderNo);



    IPage<UserAccountDetail> getUserRechargePage(Page<UserAccountDetail> pageParam, Long userId);
}
